package com.wh.wisdomsite.xbox.al.entity;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * @author 刘旭
 * @version V1.0
 * @Package com.wh.wisdomsite.xbox.al.entity
 * @date 2018年08月08日 16:59
 * @Copyright 企业版权所有
 * @Company 贵州万华科技有限公司Copyright (c) 2018
 */
@TableName("al_alarmSign")
public class AlarmSign extends Model<AlarmSign> {

    /**
     * 警报预警ID
     */
    @TableId(type = IdType.UUID)
    private String alId;

    /**
     *FK, 项目ID
     */
    @TableField("prId")
    private String prId;

    /**
     *警报来源运行记录ID
     */
    @TableField("recordId")
    private String recordId;

    /**
     *警报时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @TableField("alarmTime")
    private Date alarmTime;

    /**
     *警报类型 
     */
    @TableField("alarmType")
    private String alarmType;

    /**
     *警报类别
     */
    @TableField("alarmCategory")
    private String alarmCategory;

    /**
     *警报细分
     */
    @TableField("alarmSubdivided")
    private String alarmSubdivided;

    /**
     *设备名称
     */
    @TableField("deviceName")
    private String deviceName;

    /**
     *设备编号
     */
    @TableField("deviceId")
    private String deviceId;

    /**
     * 报警值
     */
    @TableField("alarmData")
    private String alarmData;

    /**
     * 警报处理状态，
     * 1：未处理，2：已处理
     */
    @TableField("alarmStatus")
    private String alarmStatus;

    /**
     * 处理人
     */
    @TableField("resolveUser")
    private String resolveUser;

    /**
     * 处理时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @TableField("resolveTime")
    private Date resolveTime;

    /**
     * 处理方式
     */
    @TableField("resolveContent")
    private String resolveContent;

    /**
     *警报内容
     */
    @TableField("alarmContent")
    private String alarmContent;

    /**
     * 计量单位
     */
    @TableField( exist = false)
    private String measureUnit;

    /**
     *创建者
     */
    @TableField("createBy")
    private String createBy;

    /**
     *创建时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @TableField("createDate")
    private Date createDate;

    public String getAlId() {
        return alId;
    }

    public void setAlId(String alId) {
        this.alId = alId;
    }

    public String getPrId() {
        return prId;
    }

    public void setPrId(String prId) {
        this.prId = prId;
    }

    public String getRecordId() {
        return recordId;
    }

    public void setRecordId(String recordId) {
        this.recordId = recordId;
    }

    public Date getAlarmTime() {
        return alarmTime;
    }

    public void setAlarmTime(Date alarmTime) {
        this.alarmTime = alarmTime;
    }

    public String getAlarmType() {
        return alarmType;
    }

    public void setAlarmType(String alarmType) {
        this.alarmType = alarmType;
    }

    public String getAlarmCategory() {
        return alarmCategory;
    }

    public void setAlarmCategory(String alarmCategory) {
        this.alarmCategory = alarmCategory;
    }

    public String getAlarmSubdivided() {
        return alarmSubdivided;
    }

    public void setAlarmSubdivided(String alarmSubdivided) {
        this.alarmSubdivided = alarmSubdivided;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getAlarmData() {
        return alarmData;
    }

    public void setAlarmData(String alarmData) {
        this.alarmData = alarmData;
    }

    public String getAlarmContent() {
        return alarmContent;
    }

    public void setAlarmContent(String alarmContent) {
        this.alarmContent = alarmContent;
    }

    public String getAlarmStatus() {
        return alarmStatus;
    }

    public void setAlarmStatus(String alarmStatus) {
        this.alarmStatus = alarmStatus;
    }

    public String getResolveUser() {
        return resolveUser;
    }

    public void setResolveUser(String resolveUser) {
        this.resolveUser = resolveUser;
    }

    public Date getResolveTime() {
        return resolveTime;
    }

    public void setResolveTime(Date resolveTime) {
        this.resolveTime = resolveTime;
    }

    public String getResolveContent() {
        return resolveContent;
    }

    public void setResolveContent(String resolveContent) {
        this.resolveContent = resolveContent;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getMeasureUnit() {
        switch (alarmSubdivided) {
            case "TOWER_CRANE::TURN_LEFT":
                measureUnit = "°/s";
                break;
            case "TOWER_CRANE::TURN_RIGHT":
                measureUnit = "°/s";
                break;
            case "TOWER_CRANE::HEIGHT_HIGH":
                measureUnit = "M";
                break;
            case "TOWER_CRANE::HEIGHT_LOW":
                measureUnit = "M";
                break;
            case "TOWER_CRANE::SCOPE_FRONT":
                measureUnit = "M";
                break;
            case "TOWER_CRANE::SCOPE_TAIL":
                measureUnit = "M";
                break;
            case "TOWER_CRANE::TORQUE_CROSSING":
                measureUnit = "%";
                break;
            case "TOWER_CRANE::WINDSPD_CROSSING":
                measureUnit = "m/s";
                break;
            case "ENV::PM25_CROSSING":
                measureUnit = "ug/m³";
                break;
            case "ENV::PM10_CROSSING":
                measureUnit = "ug/m³";
                break;
            case "ENV::AQI_CROSSING":
                measureUnit = "";
                break;
            case "ENV::TEMP_CROSSING":
                measureUnit = "°C";
                break;
            case "ENV::NOISE_CROSSING":
                measureUnit = "dB";
                break;
            default:
                measureUnit = "";
                break;
        }
        return measureUnit;
    }

    public void setMeasureUnit(String measureUnit) {
        this.measureUnit = measureUnit;
    }

    @Override
    protected Serializable pkVal() {
        return this.alId;
    }
}
